<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更多未办</title>
    <link rel="icon" href="img/logo.png">
    <link rel="stylesheet"href="../public/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/bootstrap-3.3.4.css">
    <script src="../public/jquery-1.12.4.js"></script>

    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .content1{
            width: 100%;
        }
        .layui-btn{
            background-color: #86a0f3;
            color: white;
        }
        .layui-laypage .layui-laypage-curr .layui-laypage-em {
            background-color: #86a0f3;
        }
        .layui-bg-blue {
            margin-top: -4px;
            background-color: #86a0f3 !important;
        }
        .content1{

            width: 100%;height:80px
        }
        #derive{
            padding-top: 10px;
            padding-left: 20px;
        }
    </style>
</head>
<body>
<div class="content1">
    <fieldset class="table-search-fieldset">
    <div style="margin: 10px 10px 10px 10px">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 90px;">事务标题:</label>
                    <div class="layui-input-inline">
                        <input id="title" type="text" name="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">开始日:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="start" name="start" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">截止日:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="end" name="end" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                </div>
            </div>

    </div>
</fieldset>
    <!--    未办任务表-->
    <div class="layui-card-body" id="table1">
        <table class="layui-hide" id="currentTableId1" lay-filter="currentTableFilter"></table>
    </div>
<!--    确定已完成-->
    <script type="text/html" id="currentTableBar1">
        <button onclick="button1(event)" class="layui-btn layui-icon layui-bg-blue">
            &#xe605;
        </button>
    </script>

</div>
<script src="../public/layui/layui.js"></script>
<script>

    layui.use(['layer','table','laydate'], function () {
        var layer = layui.layer,
            $ = layui.jquery,
            table = layui.table;

        var laydate = layui.laydate;
        laydate.render({
            elem: '#start' //指定元素
        });
        laydate.render({
            elem: '#end' //指定元素
        });

        //未办任务表
        table.render({
            elem: '#currentTableId1',
            // url: '../api/table2.1.json',
            url:'/Counselor_System/home/tasksFalseStatus',
            toolbar: 'true',
            height:500,
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'id', width: 100, title: 'id'},
                {field: 'title', width: 250, title: '事务标题'},
                {field: 'type', width: 150, title: '事务类型'},
                {field: 'task', width: 150, title: '事务分类'},
                {field: 'createTime', width: 200, title: '发布时间', sort: true},
                {field: 'finishTime', width: 200, title: '截止时间', sort: true},
                {title: '操作', minWidth: 150, toolbar: '#currentTableBar1', align: "center"}
            ]],
            skin: 'row '
            ,id: 'tableAll'//设定容器唯一 id。
            ,page: true//开启分页
            , limits: [10, 15, 20]  //一页选择显示3,5或10条数据
            , limit: 10 //一页显示6条数据
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                var result;
                // console.log(this);
                // console.log(JSON.stringify(res));
                if (this.page.curr) {
                    result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                }
                else {
                    result = res.data.slice(0, this.limit);
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": result //解析数据列表
                };
            }
        });
        //数据表格的重载
        $('.layui-btn').click(function () {
            table.reload('tableAll', {
                //url: '../api/table2.1search.json'//向后台发送请求
                url:'/Counselor_System/home/searchFalseTaskByStatusandUser'
                ,methods:"post"
                ,where: {
                    title :$('#title').val(),//搜索条件
                    start:$('#start').val(),
                    end:$('#end').val()
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        })

    });

    //操作点击完成
    function button1(e) {
        var id=e.currentTarget.parentNode.parentNode.parentNode.getElementsByTagName("td")[1].getElementsByTagName("div")[0].innerText;
        console.log(e.currentTarget.parentNode.parentNode.parentNode.remove());
        console.log(id);
        $.ajax({
            //url:'api/look/',
            url:'/Counselor_System/home/updateTaskByStatus2',
            type:'POST',
            dataType:'json',
            data:{
                id:id
            },
            success:function (res) {
                 //if (res.code==0){
                    alert('确定已完成');
                //}
            },
            error:function (res) {
                console.log(res)
            }
        })

    }


</script>

</body>
</html>